home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / mus / misc / NSM_crange.lha / copyrange / copyrange.c < prev    next >
C/C++ Source or Header  |  1999-02-23  |  2KB  |  90 lines

  1. /*
  2.     Copies the range to another track, with
  3.     the same line-numbers and the instrument
  4.     which is present on the other track.
  5.  
  6.     Made by Kjetil S. Matheussen January '99.
  7.  
  8.     This is an example on how to make an
  9.     octamed plug-in with the nsm-system.
  10.  
  11.     e-mail: kjetilma@ifi.uio.no
  12.  
  13.     Address:
  14.     Kjetil S. Matheussen
  15.     5423 Sogn Studentby
  16.     0858 Oslo
  17.     Norway
  18. */
  19.  
  20. #include <string.h>
  21. #include "/nsm.h"
  22. #include "/readstr.h"
  23.  
  24. void main(){
  25.     OCTABASE ob;
  26.     BLOCKBASE bb;
  27.  
  28.     UWORD numlines,numpages;
  29.  
  30.     UWORD starttrack,endtrack;
  31.     UWORD    startline,endline;
  32.  
  33.     UWORD line=0,page;
  34.  
  35.     int pastetrack;
  36.     int pasteinum=0;
  37.  
  38.  
  39.     APTR dosbase,filehandle;
  40.     char string[80];
  41.  
  42.     if((ob=getoctabase())==0) goto exit;            /* Allways include this line first in
  43.                                                                     your plug-ins. */
  44.     if(!isranged(ob)) goto exit;
  45.  
  46.     bb=getcurrblockbase(ob);
  47.  
  48.     starttrack=getrangestarttrack(ob);
  49.     endtrack=getrangeendtrack(ob);
  50.     startline=getrangestartline(ob);
  51.     endline=getrangeendline(ob);
  52.  
  53.     dosbase=opendoslibrary();
  54.     filehandle=openoctacon(dosbase,350,60);
  55.  
  56.     writestring(dosbase,filehandle,"To track: ",10);
  57.     readstring(dosbase,filehandle,string,70);
  58.     if(*string==0) goto close;
  59.     sscanf(string,"%d",&pastetrack);
  60.     if(pastetrack<0 || pastetrack>=getnumtracks(bb) || pastetrack==starttrack) goto close;
  61.  
  62.     numlines=getnumlines(bb);
  63.     while(pasteinum==0){
  64.         pasteinum=getinum(bb,pastetrack,line);
  65.         line++;
  66.         if(line>=numlines){
  67.             writestring(dosbase,filehandle,"Instrument: ",12);
  68.             readstring(dosbase,filehandle,string,70);
  69.             sscanf(string,"%d",&pasteinum);
  70.         }
  71.     }
  72.  
  73.     numpages=getnumpages(bb);
  74.     for(line=startline;line<=endline;line++){
  75.         setnote(bb,pastetrack,line,getnote(bb,starttrack,line));
  76.         if(getnote(bb,starttrack,line)>0) setinum(bb,pastetrack,line,pasteinum);
  77.         for(page=1;page<=numpages+1;page++){
  78.             setcmdnum(bb,pastetrack,line,page,getcmdnum(bb,starttrack,line,page));
  79.             setcmdlvl(bb,pastetrack,line,page,getcmdlvl(bb,starttrack,line,page));
  80.         }
  81.     }
  82.     updateeditor(ob);
  83.  
  84. close:
  85.     closefile(dosbase,filehandle);
  86.     closedoslibrary(dosbase);
  87.  
  88. exit:
  89. }
  90.